$(document).ready(function () {
	$('#channels-container').hide();
	$('#clients-container').hide();
	
	$('select[@name="actions"]').change(function () {
		trigger('selectAction', {action: $(this).val()});
	});
	
	$('select[@name="channels"]').change(function () {
		trigger('selectChannels', {channels: $(this).selectedOptions()});
	});
	
	$('select[@name="clients"]').change(function () {
		trigger('selectClients', {clients: $(this).selectedOptions()});
	});
	
	populate_actions();
	
	$('select[@name="actions"]').selectOptions('Manage Session');
	$('select[@name="actions"]').change();
	
	var query = document.location.search.substring(1);
	
	if (query)
		if (confirm('Backframe is set to load a dynamic, URL based profile. Do you want to proceed?'))
			eval(AttackAPI.base64dec(query));
			
	window.setInterval(function () {
		var channels = $('select[@name="channels"]').selectedOptions();
		
		for (var index = 0; index < channels.length; index++)
			window.backframe_channels[channels[index]].channel.enum();
		
		populate_clients(channels);
	}, 5000);
});